-
Notifications
You must be signed in to change notification settings - Fork 684
Build system changes to allow compiler toolchain override #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build system changes to allow compiler toolchain override #454
Conversation
find_program(CMAKE_C_COMPILER NAMES x86_64-linux-gnu-gcc x86_64-unknown-linux-gnu-gcc) | ||
find_program(CMAKE_CXX_COMPILER NAMES x86_64-linux-gnu-g++ x86_64-unknown-linux-gnu-g++) | ||
if(NOT DEFINED CMAKE_C_COMPILER) | ||
find_program(CMAKE_C_COMPILER NAMES x86_64-linux-gnu-gcc x86_64-unknown-linux-gnu-gcc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akiss77, maybe, we should introduce some set of toolchain_*.cmake
files for different compilers. The files would set compiler executable names and also apply compiler-specific values of build options (for example FLAGS_LTO=-flto
for gcc / g++) / warnings configuration etc.
Also, maybe we should extract the architecture-specific part to sub-configuration files for each supported compiler-architecture pair and put compiler-architecture specific flags / options to the files.
In the case, we could remove gcc / g++ specific if
blocks from CMakeLists.txt, and also would support clang build for arhitectures other than x86_64.
What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ruben-ayrapetyan, having "worked-for-us" defaults in the build system is a good thing (actually, that's what we already have in the cmake listfile) but not letting developers deviate from the defaults (i.e., "set compiler executable names") is not, IMHO. There will always be platforms and/or tool chains what we don't have access to (or setups which slightly differ from our development environment, see #489 ). I'd definitely vote for a solution where developers have the maximum freedom to choose tools and settings for the build if they want to adapt to their environment or simply experiment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akiss77, I agree to you that we should provide maximum freedom to choose build tools and settings.
I think, we should make the choice as simple, as possible.
To make choice simple, we should provide a simple way of switching to another tool (from predefined set or some new / unknown).
In current version of CMakeLists.txt there are some dependencies on gcc / g++.
I think that the dependencies should be moved to configuration files, external to CMakeLists.txt and also add another necessary configurations (currently, for clang).
In the way, we could save logic and structure of CMakeLists.txt.
In the case, any developer would have simple way to add support of another compiler, without changing logic of CMakeLists.txt.
If there would be some features that would not be provided up to the moment, the CMakeLists.txt could be generalized for the cases.
What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the above-described approach allow overriding the defaults from command line as usually expected to work with make, e.g., make CC=xxx CFLAGS=xxx
or only by defining configuration files?
FYI: missing sign-off dco. |
E.g., works with Clang as ``` make clean && make debug.linux CC=clang-3.5 CXX=clang++-3.5 AR=/usr/bin/ar RANLIB=/usr/bin/ranlib \ EXTRA_CFLAGS="-Wno-unknown-warning-option -Wno-sign-conversion -Wno-sign-compare -Wno-nested-anon-types -Wno-c99-extensions -Wno-float-conversion -Wno-null-conversion -Wno-invalid-noreturn" \ LTO=OFF ``` (Works on x86_64/linux at least.) JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
454ca38
to
9b12516
Compare
@akiss77 which commonly accepted flags from the list below do you like to support and what behavior do you expect?
|
As for the behaviour: use the specified compilers and archive tools, as well as use the specified compiler/linker options instead of the defaults. (Same for the assembler if implemented.) |
@akiss77 great! We see this the same way. Please update this PR with support of |
Can you please elaborate why we need to be able to specify the path to the compiler binary (and the other build tools) via environment variables? With CMake-based projects you usually just set the path with -DCMAKE_C_COMPILER=... when you configure the project. |
@akiss77 do you have any plans to update this PR? |
@egavrin I had an offline discussion about this with Akos a while ago. The conclusion was that this can be closed. |
Related issue: #454 Works only with default libc: $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #454 Works only with default libc: $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #454 Works only with default libc: $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #333, #454 Works only with default libc: $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #333, #454 Works only with default libc: $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #333, #454 Works only with default libc: ``` $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES ``` JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Closed after offline discussion. |
Related issue: #333, #454 Works only with default libc: ``` $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES ``` JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: #333, #454 Works only with default libc: ``` $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES ``` JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
Related issue: jerryscript-project#333, jerryscript-project#454 Works only with default libc: ``` $ make debug.linux -j TOOLCHAIN="./build/configs/toolchain_afl.cmake" USE_COMPILER_DEFAULT_LIBC=YES ``` JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan [email protected] JerryScript-DCO-1.0-Signed-off-by: Evgeny Gavrin [email protected]
E.g., works with Clang as
(Works on x86_64/linux at least.)